{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  function generateUrl(name) {
    var sanitizedName = name;
    sanitizedName = sanitizedName.replace(/ el /gi, ' ');
    sanitizedName = sanitizedName.replace(/ la /gi, ' ');
    sanitizedName = sanitizedName.replace(/ los /gi, ' ');
    sanitizedName = sanitizedName.replace(/ las /gi, ' ');
    sanitizedName = sanitizedName.replace(/ de /gi, ' ');
    sanitizedName = sanitizedName.replace(/ del /gi, ' ');
    sanitizedName = sanitizedName.replace(/ temporada /gi, ' ');
    sanitizedName = string_to_slug(sanitizedName);
    sanitizedName = sanitizedName.replace(/--/gi, '-');
    sanitizedName = sanitizedName.replace(/---/gi, '-');
    sanitizedName = sanitizedName.replace(/----/gi, '-');
    $("#slug").val(sanitizedName);
  }
  $(window).load(
    function() {
      $( "#firstPost" ).datepicker({ dateFormat: 'yy-mm-dd 00:00:00.000000' });
    });
</script>
{% endblock %}
{% block content %}
        <h1>directory</h1>
        <form action="/admin/directories/{{ directory.key }}/save/" method="post">
        
        <div class="line">
          <div class="field">
            <label>Name:</label>
            <input id="name" name="name" type="text" size="30" value="{{ directory.name }}" onblur="generateUrl(this.value);"  />
          </div>
          <div class="field">
            <label>URL:</label>
            <input id="url" name="url" type="text" size="40" value="{{ directory.url }}" />
          </div>
          <div class="field">
            <label>Internal name:</label>
            <input id="intname" name="intname" type="text" size="30" value="{{ directory.intname }}" onblur="generateUrl(this.value);"  />
          </div>
          <div class="field">
            <label>Language:</label>
            <select name="language">
              <option value="es"{% ifequal directory.language "es" %} selected="selected"{% endifequal %}>es</option>
              <option value="es_ES"{% ifequal directory.language "es_ES" %} selected="selected"{% endifequal %}>es_ES</option>
              <option value="en"{% ifequal directory.language "en" %} selected="selected"{% endifequal %}>en</option>
            </select>
          </div>
        </div>
        <input type="submit" value="Guardar" id="save" name="save" name="save" /><br class="clear" />
      </form>
      <br class="clear" />

{% endblock %}
      